/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ps.util;

/**
 *
 * @author Admin
 */
public class b64 {
      public static String Encode(int i) 
    { 
        try 
        { 
            String s = ""; 
            for (int x = 1; x <= 2; x++) 
                s += (char)((byte)(64 + (i >> 6 * (2 - x) & 0x3f))); 
            return s; 
        } 
        catch (Exception e) 
        { 
            System.out.println(e.toString()); 
            return ""; 
        }         
    } 
    public static int Decode(String s) 
    { 
        try 
        { 
            char[] val = s.toCharArray(); 
            int intTot = 0; 
            int y = 0; 
            for (int x = (val.length - 1); x >= 0; x--) 
            { 
                int intTmp = (int)(byte)((val[x] - 64)); 
                if (y > 0) 
                    intTmp = intTmp * (int)(Math.pow(64, y)); 
                intTot += intTmp; 
                y++; 
            } 
            return intTot; 
        }     
        catch (Exception e) 
        { 
            System.out.println(e.toString()); 
            return 0; 
        }     
    } 
}  
    
